package implementor;



import model.GinItems;
import dao.GinItemsDao;
import dbhandelling.Crude;



public class GinItemsImplementor extends Crude implements GinItemsDao
{
	String className=new GinItems().getClass().getName();
	@Override
	public void add(GinItems ginItems) throws Exception 
	{
		insert(ginItems);
	}

	@Override
	public void update(GinItems ginItems) throws Exception 
	{
		super.update(className, "specCode", ginItems.getSpecCode()+"", "autoGinNumber",ginItems.getAutoGinItemsNumber()+"");

		super.update(className, "mCode", ginItems.getmCode()+"", "autoGinNumber",ginItems.getAutoGinItemsNumber()+"");

		super.update(className, "mReceivedQuant", ginItems.getmReceivedQuant()+"", "autoGinNumber",ginItems.getAutoGinItemsNumber()+"");

		super.update(className, "ginNo", ginItems.getGinNo()+"", "autoGinNumber",ginItems.getAutoGinItemsNumber()+"");

		
	}

	@Override
	public void delete(GinItems ginItems) throws Exception 
	{
		delete(className,"autoGinNumber",ginItems.getAutoGinItemsNumber()+"");
	}

	@Override
	public GinItems retreive(String conditionField, String ConditionValue) throws Exception 
	{
		GinItems ginItems=(GinItems) super.retreive(className,conditionField, ConditionValue);
		return ginItems;
	}

	@Override
	public GinItems[] retreiveArray(String conditionField, String conditionValue) throws Exception 
	{
		GinItems[] ginItemss;
		Object[] obj=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		ginItemss=new GinItems[obj.length];
		
		for(int i=0;i<ginItemss.length;i++)
		{
			ginItemss[i]=(GinItems) obj[i];
		}
		
		return ginItemss;
	}

	@Override
	public GinItems[] retreiveAll() throws Exception 
	{
		GinItems[] ginItemss;
		
		Object[] obj=super.retreiveAll(className);
		
		ginItemss=new GinItems[obj.length];
		
		for(int i=0;i<ginItemss.length;i++)
		{
			ginItemss[i]=(GinItems) obj[i];
		}
		
		return ginItemss;
	}

}
